package org.linlinjava.litemall.wx.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.linlinjava.litemall.wx.annotation.LogAnno;
import org.linlinjava.litemall.wx.annotation.LoginUser;
import org.linlinjava.litemall.wx.dto.PointExchangeOrderDTO;
import org.linlinjava.litemall.wx.service.WxPointExchangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api("积分兑换API")
@RestController
@RequestMapping("/wx/pointExchange")
@Validated
public class PointExchangeController {

    @Autowired
    private WxPointExchangeService wxPointExchangeService;

    @ApiOperation("查询所有的积分兑换")
    @GetMapping("listAllPointExchange")
    @LogAnno
    public Object listAllPointExchange(){
        return wxPointExchangeService.listAllPointExchange();
    }

    @ApiOperation("查出指定积分兑换的商品三级分类")
    @GetMapping("categoryPointExchange")
    @LogAnno
    public Object categoryPointExchange(Integer pointExchangeId){
       return  wxPointExchangeService.categoryPointExchange(pointExchangeId);
    }

    @ApiOperation("通过三级分类查询可兑换商品")
    @GetMapping("pointExchangeByCategoryId")
    @LogAnno
    public Object pointExchangeByCategoryId(@RequestParam Integer categoryId,Integer pointExchangeId,Integer shopId){
        return wxPointExchangeService.pointExchangeByCategoryId(categoryId,pointExchangeId,shopId);
    }

    @ApiOperation("查询商品信息，规格，属性，添加辅料")
    @GetMapping("goodDetailAndExchange")
    @LogAnno
    public Object goodDetailAndExchange(@RequestParam Integer goodsId){
        return wxPointExchangeService.goodDetailAndExchange(goodsId);
    }

    @ApiOperation("积分兑换下单")
    @PostMapping("orderByPoint")
    @LogAnno
    public Object orderByPoint(@LoginUser Integer userId, @RequestBody PointExchangeOrderDTO dto){
        return wxPointExchangeService.orderByPoint(userId,dto);
    }
}
